package com.pug.zixun.service.courseorder;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pug.zixun.bo.OrderBo;
import com.pug.zixun.commons.utils.SnowflakeIdWorker;
import com.pug.zixun.mapper.CourseOrderMapper;
import com.pug.zixun.pojo.CourseOrder;
import com.pug.zixun.pojo.Order;
import com.pug.zixun.service.order.IOrderService;
import com.pug.zixun.vo.CourseOrderVo;
import com.pug.zixun.bo.CourseOrderBo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import com.pug.zixun.commons.enums.ResultStatusEnum;
import com.pug.zixun.commons.ex.PugValidatorException;
import com.pug.zixun.commons.utils.fn.asserts.Vsserts;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;



/**
 * CourseOrderServiceImpl实现类
 * 创建人:yykk<br/>
 * 时间：2022-09-09 12:32:33 <br/>
 * 源码下载：前台代码 git clone https://gitee.com/kekesam/kuangstudy-pug-ui.git
 * 飞哥B站地址：后台代码 git clone https://gitee.com/kekesam/kuangstudy-pug-parent.git
 * @version 1.0.0<br/>
 *
*/
@Service
@Slf4j
@RequiredArgsConstructor
public class CourseOrderServiceImpl extends ServiceImpl<CourseOrderMapper,CourseOrder> implements ICourseOrderService  {

    private final IOrderService iOrderService;
    @Override
    public List<CourseOrderBo> findCourseOrderList() {
        return null;
    }

    @Override
    public IPage<CourseOrderBo> findCourseOrderPage(CourseOrderVo courseorderVo) {
        return null;
    }

    @Override
    public CourseOrderBo saveupdateCourseOrder(CourseOrder courseorder) {
        String ordernumber = new SnowflakeIdWorker(1, 1).nextId() + "";
        courseorder.setOrdernumber(ordernumber);
        boolean saveOrUpdate = this.saveOrUpdate(courseorder);
        Order order=new Order();
        BeanUtils.copyProperties(courseorder,order);
        order.setType(1);
        order.setPayid(courseorder.getCourseid());
        order.setStatus(1);
        order.setIsdiscount(0);
        order.setIsdelete(0);
        order.setTitle(courseorder.getCoursetitle());
        order.setImg(courseorder.getCourseimg());
        order.setPaymoney(courseorder.getPaymoney());
        order.setRealprice(courseorder.getCoursemoney());
         OrderBo orderBo = iOrderService.saveupdateOrder(order);
        return saveOrUpdate?tranferBo(courseorder,CourseOrderBo.class):null;
    }

    @Override
    public int deleteCourseOrderById(Long id) {
        return 0;
    }

    @Override
    public CourseOrderBo getCourseOrderById(Long id) {
        return null;
    }

    @Override
    public boolean delBatchCourseOrder(String ids) {
        return false;
    }


}
